package com.sky.controller.admin;

import com.sky.dto.SetmealDTO;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.result.Result;
import com.sky.service.SetmealService;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/setmeal")
public class SetmealController {
	
	private final SetmealService setmealService;
	
	public SetmealController(SetmealService setmealService) {this.setmealService = setmealService;}
	
	
	@PostMapping
	public Result addSetmeal(@RequestBody SetmealDTO setmealDTO) {
		return setmealService.addSetmeal(setmealDTO);
	}
	
	@GetMapping("/page")
	public Result setmealPage(SetmealPageQueryDTO pageQueryDTO) {
		return setmealService.setmealPage(pageQueryDTO);
	}
	
	@DeleteMapping
	public Result deleteSetmeal(@RequestParam List<Long> ids) {
		return setmealService.deleteSetmeal(ids);
	}
	
	@GetMapping("/{id}")
	public Result getSetmealById(@PathVariable Long id) {
		return setmealService.getSetmealById(id);
	}
	
	@PutMapping
	public Result updateSetmeal(@RequestBody SetmealDTO setmealDTO) {
		return setmealService.updateSetmeal(setmealDTO);
	}
	
	@PostMapping("/status/{status}")
	public Result banSetmeal(@PathVariable Integer status, Long id) {
		return setmealService.banSetmeal(status, id);
	}
}
